package advertising

import (
	"gitee.com/alex_li/amazon-rpt/internal/rest"
	"github.com/lishimeng/go-log"
)

type SponsoredProductsEntityStateFilter struct {
	Include []string `json:"include,omitempty"`
}

type CampaignListReq struct {
	NextToken   string      `json:"nextToken,omitempty"`
	MaxResults  int         `json:"maxResults,omitempty"`
	StateFilter *TextFilter `json:"stateFilter"`
}

type CampaignInfo struct {
	CampaignId  string `json:"campaignId,omitempty"`
	Name        string `json:"name,omitempty"`
	PortfolioId string `json:"portfolioId,omitempty"`
}

type CampaignListResp struct {
	Campaigns []CampaignInfo `json:"campaigns,omitempty"`
	AmazonPager
}

func (c *Client) GetCampaigns(request CampaignListReq) (resp CampaignListResp, err error) {
	const action = "/sp/campaigns/list"
	req, err := c.request()
	if err != nil {
		log.Info(err)
		return
	}
	err = req.Path(action).Response(&resp).Body(request).
		Accept("application/vnd.spcampaign.v3+json").
		Json(rest.POST, "application/vnd.spcampaign.v3+json")
	if err != nil {
		log.Info(err)
		return
	}
	return
}
